<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${namespace}">
    <resultMap id="BaseResultMap" type="${entityFullName}">
    <#list columnPropertyMapping?keys as key>
        <#if key == primaryKey>
            <id column="${key}" property="${columnPropertyMapping[key]}" />
            <#else >
            <result column="${key}" property="${columnPropertyMapping[key]}" />
        </#if>
    </#list>
    </resultMap>
    <sql id="Base_Column_List">
        <#list columnList as column>`${column}`<#if column_has_next>, </#if></#list>
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from `${tableName}`
        where ${primaryKey} = <#noparse>#{</#noparse>${columnPropertyMapping[primaryKey]}}
    </select>
    <delete id="deleteByPrimaryKey">
        delete from `${tableName}`
        where ${primaryKey} = <#noparse>#{</#noparse>${columnPropertyMapping[primaryKey]}}
    </delete>
    <insert id="insert" parameterType="${entityFullName}">
        insert into `${tableName}` (<#list columnList as column>`${column}`<#if column_has_next>, </#if></#list>)
        values (<#list propertyList as property><#noparse>#{</#noparse>${property}}<#if property_has_next>, </#if></#list>)
    </insert>
    <insert id="insertSelective" parameterType="${entityFullName}">
        insert into `${tableName}`
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <#list columnList as column>
                <if test="${columnPropertyMapping[column]} != null">
                    `${column}`,
                </if>
            </#list>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <#list propertyList as property>
                <if test="${property} != null">
                    <#noparse>#{</#noparse>${property}},
                </if>
            </#list>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="${entityFullName}">
        update `${tableName}`
        <set>
            <#list columnList as column>
                <if test="${columnPropertyMapping[column]} != null">
                    `${column}` = <#noparse>#{</#noparse>${columnPropertyMapping[column]}},
                </if>
            </#list>
        </set>
        where ${primaryKey} = <#noparse>#{</#noparse>${columnPropertyMapping[primaryKey]}}
    </update>
    <update id="updateByPrimaryKey" parameterType="${entityFullName}">
        update `${tableName}`
        set
        <#list columnList as column>
            `${column}` = <#noparse>#{</#noparse>${columnPropertyMapping[column]}}<#if column_has_next>, </#if>
        </#list>
        where ${primaryKey} = <#noparse>#{</#noparse>${columnPropertyMapping[primaryKey]}}
    </update>
    <select id="selectList" resultMap="BaseResultMap" parameterType="${conditionFullName}">
        select <include refid="Base_Column_List"/> from `${tableName}`
        <where>
            <#list columnList as column>
                <if test="${columnPropertyMapping[column]} != null">
                    AND `${column}` = <#noparse>#{</#noparse>${columnPropertyMapping[column]}}
                </if>
            </#list>
        </where>
    </select>
</mapper>